﻿/*-------------------------------------------------------------------------
* 命名空间: XrayDirection.Services/MessageProvider
* 类       名: MessageProvider
* 功      能:  TD
* 时      间:  2023/12/28 17:52:09
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using Prism.Services.Dialogs;
using SiliconSelect.Common;
using System;
using System.Windows;
using XrayDirection.Dialogs;

namespace XrayDirection.Services
{
    public static class MessageProvider
    {
        public static void ShowError(string message, string? title = null)
        {
            LogHelper.WriteLog(message);
            MessageBox.Show(message, title);
        }

        public static void ShowException(Exception exception, string Message)
        {
            var dialogService = ServiceProvider.Get<IDialogService>();
            DialogParameters parameters = new DialogParameters();
            parameters.Add("Exception", exception);
            parameters.Add("Message", Message);
            dialogService.ShowDialog(nameof(ErrorDetailDialog), parameters, res => { });
        }

        /// <summary>
        /// 显示普通的消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="title"></param>
        public static void ShowInfo(string message, string title)
        {
            MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Information);
        }

        /// <summary>
        /// 显示带有选项的消息,比如Yes或者No,
        /// </summary>
        /// <param name="message"></param>
        /// <param name="Title"></param>
        /// <returns></returns>
        public static bool ShowOKCancel(string message, string title)
        {
            MessageBoxResult res = MessageBox.Show(message, title, MessageBoxButton.OKCancel, MessageBoxImage.Error);
            if (res == MessageBoxResult.OK)
            {
                return true;
            }
            return false;
        }
    }
}
